package com.rest.demo.functional.io;

import java.io.IOException;
import java.nio.file.*;
import java.util.stream.Collectors;

/**
 * @author Administrator
 * @decription
 * @Date 2018-01-29 15:12
 */
public class NioDemo {

    public static void main(String[] args) throws IOException {
        byte[] bytes = Files.readAllBytes(Paths.get("F:\\a.txt"));
        String result = new String(bytes,"UTF-8");
        System.out.println(result);

        String resultStr = Files.readAllLines(Paths.get("F:\\a.txt"))
                .stream()
                .collect(Collectors.joining("\n"));
        System.out.println(resultStr);

        //写入
        Path path = Files.write(Paths.get("F:\\b.txt"),"hello jdk8".getBytes(), StandardOpenOption.APPEND);
        System.out.println(path.getFileName());
    }
}
